package com.example.im.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用于非容器管理bean在系统启动后访问spring容器上下文的功能.
 */
@Configuration
public class AppContext {

    private static ApplicationContext context;

    public static ApplicationContext getContext() {
        return context;
    }

    @Bean("projectContext")
    public AppContext appContext(ApplicationContext ctx) {
        context = ctx;
        return this;
    }
}
